﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Xml;
using System.IO;
using System.Net;
using System.Data.SqlClient;
using System.Xml.Linq;
using System.Data;
using System.Timers;
namespace FB_VB_Contract_Syn
{
    static class Program
    {

        /*[STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        */

        static void Main(string[] args)
        {
            try
            {
                AppDomain currentDomain = AppDomain.CurrentDomain;
                Config config = new Config();
                Fishbowl Fishbowl = new Fishbowl();
                DataUtility Utility = new DataUtility();
                String key = "";
                config.start();

                ConnectionObject connectionObject = new ConnectionObject();
                connectionObject = config.ReturnConnection();
                key = config.ReturnKey();
                string OrderSql_VBInvoice = "select distinct order_item_delivery_type ,CONVERT(VARCHAR(10), order_item_delivery_date, 23) as deliverydate,order_item_delivery_location from order_item_delivery_tbl " +
                                           "left join order_item_delivery_type_tbl on order_item_delivery_type_tbl.order_item_delivery_id = order_item_delivery_tbl.order_item_delivery_id " +
                                           "where order_item_delivery_date > = '2012-08-01'" +
                                           "and order_item_delivery_invoice_number = 0 and order_item_delivery_tbl.order_item_delivery_id not in " +
                                         "(select order_item_delivery_id from order_item_delivery_fb_tbl)";
                  
                //string OrderSql_VBInvoice = "select distinct order_item_delivery_type ,CONVERT(VARCHAR(10), order_item_delivery_date, 23) as deliverydate,order_item_delivery_location from order_item_delivery_tbl " +
                //                            "left join order_item_delivery_type_tbl on order_item_delivery_type_tbl.order_item_delivery_id = order_item_delivery_tbl.order_item_delivery_id " +
                //                            "where order_item_delivery_tbl.order_item_delivery_id > 440463  and order_item_delivery_invoice_number <> 0 ";
                //Final

                //string OrderSql_VBInvoice = "select distinct order_item_delivery_type ,CONVERT(VARCHAR(10), order_item_delivery_date, 23) as deliverydate,order_item_delivery_location from order_item_delivery_tbl " +
                //                          "left join order_item_delivery_type_tbl on order_item_delivery_type_tbl.order_item_delivery_id = order_item_delivery_tbl.order_item_delivery_id " +
                //                           "where  order_item_delivery_date  > '2012-09-19'  and (order_item_delivery_date <'2012-09-21')  " +
                //    // "where  (order_item_delivery_date between DATEADD(d,DATEDIFF(d,1,getdate()),0) and DATEADD(d,DATEDIFF(d,0,getdate()),0)) " +
                //    "and order_item_delivery_tbl.order_item_delivery_id not in (select order_item_delivery_id from order_item_delivery_fb_tbl) " +
                //                          "and order_item_delivery_invoice_number = 0  and  order_item_delivery_location='BRISBANE' and order_item_delivery_type= 08";
                 

                string Sonumber = Utility.SaveSO1(OrderSql_VBInvoice, connectionObject, key);
                //Utility.SavePick(connectionObject, key, "VB20120908-24-BNE");
                //Utility.SaveShip(connectionObject, key, "VB20120908-24-BNE", "2012-09-08");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                DataUtility.sendEmail(e.Message.ToString());
            }
        }
        static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e)
        {
            DataUtility.sendEmail(e.ToString());
        }
      
    }
}

